package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.erp.R
import com.erp.bean.JingXiHuaBean
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_jingxihua_item.view.*

/**
 * Created by Administrator on 2019/4/13/013.
 * 作者：刘洋
 */
class JingXiHuaAdapter(private var list : MutableList<JingXiHuaBean>, val context : Context) : BaseAdapter(){
    private val minfalter: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v : View
        var vh : ViewHolder
        if(convertView==null){
            v = minfalter.inflate(R.layout.lv_jingxihua_item, null)
            vh = ViewHolder(v)
            v.tag = vh
        }else{
            v = convertView
            vh = convertView.tag as ViewHolder
        }
        var bean = list.get(position)
        Myutil.settv(bean.content_scheme,vh.TvContentScheme)
        Myutil.settv(bean.file_category,vh.TvFileCategory)
        Myutil.settv(bean.state,vh.TvState)
        Myutil.settv(bean.duty_name,vh.TvDutyName)
        Myutil.settv(bean.ctime,vh.TvCtime)
        Myutil.settv(bean.audit_name,vh.TvAuditName)
        Myutil.settv(bean.audit_time,vh.TvAuditTime)
        Myutil.settv(bean.approval_name,vh.TvApprovalName)
        Myutil.settv(bean.approval_time,vh.TvApprovalTime)
        return v
    }

    override fun getItem(position: Int): Any {
        return list.get(position)
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return list.size
    }

    class ViewHolder(v: View) {
        var TvContentScheme: TextView = v.TvContentScheme
        var TvFileCategory: TextView = v.TvFileCategory
        var TvState: TextView = v.TvState
        var TvDutyName: TextView = v.TvDutyName
        var TvCtime: TextView = v.TvCtime
        var TvAuditName: TextView = v.TvAuditName
        var TvAuditTime: TextView = v.TvAuditTime
        var TvApprovalName: TextView = v.TvApprovalName
        var TvApprovalTime: TextView = v.TvApprovalTime
    }
}